#[macro_use]
extern crate log;

#[macro_use]
extern crate serde_derive;

extern crate tungstenite as ws;
extern crate serde;
#[macro_use]
extern crate serde_json;

extern crate mio;

mod conf;
mod chess;
mod net;
//mod db;
mod game;
mod control;

use std::thread;
use std::time::Duration;

static mut INDEX: u32 = 100;

fn main() {
    //初始化日志配置
    conf::logger::logger_init();

    info!("MyProgram v0.0.1 starting up!");
    debug!("DEBUG output enabled.");
    trace!("TRACE output enabled.");
    // Emulate a library we're using which has tons of debugging on the 'info' level.
    info!(target: "overly-verbose-target", "hey, another library here, we're starting.");


    //启动游戏循环
    control::run();
//    loop{
//        let index = new_index();
//        println!("Index value {}", index);
//        thread::sleep(Duration::from_millis(500));
//    }
}

fn new_index() -> u32{
    unsafe {
        if INDEX > 199{
            INDEX = 100;
        }
        INDEX = INDEX + 1;
        INDEX
    }
}